home *** CD-ROM | disk | FTP | other *** search
- /*
- CDElapsedTrack - An XFCN to report elapsed time on disc
- ©Apple Computer, Inc. 1988
- All Rights Reserved.
-
- 88/11/08 BL°B First Version
-
- To compile and link this file using Macintosh Programmer's Workshop,
-
- C -q2 CDElapsedTrack.c
- link -sn Main=CDElapsedTrack -sn STDIO=CDElapsedTrack ∂
- -sn INTENV=CDElapsedTrack -rt XFCN=42 ∂
- -m CDElapsedTrack CDElapsedTrack.c.o "{CLibraries}"CRuntime.o ∂
- "{CLibraries}"StdCLib.o ∂
- -o HyperCommands
-
- This link directive puts the XCMD in the file "HyperCommands".
- Substitute the name of the stack you want it in. To move XCMDs
- between stacks, use ResEdit. They can be in an individual stack,
- the Home stack, the HyperCard application, or the System File.
-
- */
-
- #include <cd.h>
-
- /* prototype definitions for functions */
-
- /* **** WARNING: DO NOT USE GLOBAL VARIABLES! **** */
-
-
- /************************************************************************
- *
- * Function: CDElapsedTrack
- *
- * Purpose: return the elapsed time on this disc.
- *
- * Returns: either 0, or an error
- * if it's a negative number, it's an error
- *
- * Side Effects:
- *
- * Description: We need no parameters.
- * Get the ioRefNum that we got from previously calling
- * CDOpen() from its famous global name
- * call the driver with a READQ call to find out
- * how absolute minute, second, block elapsed.
- *
- ************************************************************************/
- pascal void
- CDElapsedTrack(paramPtr)
- XCmdBlockPtr paramPtr;
- {
- Str31 returnString;
- OSErr result;
- short ioRefNum;
- Handle refHandle;
- long Elapsed[4]; /* minute, second, block */
- long currentMinute, currentSecond, currentBlock;
- long startMinute, startSecond, startBlock;
-
- /* Must be no parameters */
- if ((paramPtr->paramCount) != 0)
- {
- /* Report error in parameters by returning -1 */
- NumToStr(paramPtr, (long) -1, &returnString);
- paramPtr->returnValue = PasToZero(paramPtr, (StringPtr) &returnString);
- return;
- }
-
- /* Get the global ioRefNum and convert it. */
- refHandle = GetGlobal(paramPtr, GLOBALNAME);
- ioRefNum = atoi(*(refHandle));
- DisposHandle(refHandle);
- ioRefNum &= 0xFFFF; /* remove vRefNum; not needed. */
-
-
- result = ReadQ(ioRefNum, &Elapsed[0], ¤tMinute, ¤tSecond, ¤tBlock);
-
- if (result == noErr)
- result = TrackStart(ioRefNum, Elapsed[0], &startMinute, &startSecond, &startBlock);
-
- if (result == noErr)
- {
- TimeDiff(&Elapsed[1], &Elapsed[2], &Elapsed[3],
- currentMinute, currentSecond, currentBlock,
- startMinute, startSecond, startBlock);
- }
-
- if (result == noErr)
- {
- /* convert each value to a string, concatenate, & return. */
- FormatString(&returnString, Elapsed, 4);
- paramPtr->returnValue = PasToZero(paramPtr, (StringPtr) &returnString);
- }
- else
- {
- /* We got an error. Convert result to string & return it as error */
- NumToStr(paramPtr, (long) result, &returnString);
- paramPtr->returnValue = PasToZero(paramPtr, (StringPtr) &returnString);
- }
- }
-
-
- /* C routines for HyperCard callbacks */
- #include <XCmdGlue.inc.c>
-